package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException {


            Scanner input = new Scanner(System.in);

            FileOutputStream fos = new FileOutputStream("./test/pw2.txt",true);

            OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);

            BufferedWriter bw = new BufferedWriter(osw);

            PrintWriter pw = new PrintWriter(bw,true);

        while (true){

            System.out.println("请输入文本,想退出则输入exit");

            String text = input.nextLine();


            if ("exit".equals(text)){
                break;
            }

            pw.println(text);
        }
        System.out.println("写出完毕");
        pw.close();
    }
}
